package com.lemon.controller;
import com.lemon.domain.OutboundOrderDetails;
import com.lemon.domain.OutboundOrderWeights;
import com.lemon.domain.PageResult;
import com.lemon.domain.vo.TransportVo;
import com.lemon.service.OutboundOrderDetailsService;
import com.lemon.service.OutboundOrderWeightsService;
import com.lemon.service.impl.OutboundOrderWeightsServiceImpl;
import com.lemon.domain.Result;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

/**
 * 出库单称重记录表(outbound_order_weights)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/outbound_order_weights")
public class OutboundOrderWeightsController {
    /**
     * 服务对象
     */
    @Autowired
    private OutboundOrderWeightsService outboundOrderWeightsService;
    @Autowired
    private OutboundOrderDetailsService outboundOrderDetailsService;

    @PutMapping
    public Result chengZhong(Long id){
        outboundOrderWeightsService.chengZhong(id);
        return Result.success();
    }

    @GetMapping("/list")
    public Result listed(Integer page,Integer pageSize, String invoiceCode){
        PageResult list = outboundOrderWeightsService.getPageTwo(page, pageSize, invoiceCode);
        return Result.success(list);
    }

    @GetMapping
    public Result list(Integer page,Integer pageSize, String invoiceCode){
        PageResult list = outboundOrderWeightsService.getPage(page, pageSize, invoiceCode);
        return Result.success(list);
    }

    @PostMapping("/transport")
    public Result transport(@RequestBody TransportVo  transport){
        outboundOrderWeightsService.transport(transport);
        return Result.success();
    }

    @PutMapping("/status")
    public Result updateStatus(Long id,Integer status){
        OutboundOrderDetails byId = outboundOrderDetailsService.getById(id);
        byId.setStatus( status);
        outboundOrderDetailsService.updateById(byId);
        return Result.success();
    }
}
